/*
 * TestingClass.cpp
 *
 */

#include "TestingClass.h"
#include <math.h>
#include "sgp4_date.h"
#include "sgp4_math.h"
#include "sgp4_util.h"


CPPUNIT_TEST_SUITE_REGISTRATION(TestingClass);



void TestingClass::setUp(){}


void TestingClass::tearDown(){}



void TestingClass::testComprobarFechas(){
	 	double jd;double  salida;
	 	int  year; int mon; int day; int hr; int min;double sec;
		jd=2456020.010;


		sgp4_date::invjday(jd,year,mon,day,hr,min,sec);
		sgp4_date::jday(year,mon,day,hr,min,sec,salida);

		CPPUNIT_ASSERT_EQUAL_MESSAGE("Año no correcto",2012,year);
		CPPUNIT_ASSERT_EQUAL_MESSAGE("Mes no correcto",4,mon);
		CPPUNIT_ASSERT_EQUAL_MESSAGE("Dia no correcto",2,day);
		CPPUNIT_ASSERT_EQUAL_MESSAGE("Hora no correcta",12,hr);
		CPPUNIT_ASSERT_EQUAL_MESSAGE("Minuto no correcto",14,min);
		CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Segundo no correcto ",24,sec,0.01f);
		CPPUNIT_ASSERT_DOUBLES_EQUAL(jd,salida,0.00001f);


}

void TestingClass::testDiaBisiesto(){
	 	double jd;double  salida;
	 	int  year; int mon; int day; int hr; int min;double sec;
	 	jd=2488129.008472;
	 	sgp4_date::invjday(jd,year,mon,day,hr,min,sec);
	 	sgp4_date::jday(year,mon,day,hr,min,sec,salida);

	 	CPPUNIT_ASSERT_DOUBLES_EQUAL(jd,salida,0.00001f);

	 	CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Segundo no correcto ",12,sec,0.1f);
	 	CPPUNIT_ASSERT_EQUAL_MESSAGE("Minuto no correcto",12,min);
	 	CPPUNIT_ASSERT_EQUAL_MESSAGE("Hora no correcta",12,hr);
	 	CPPUNIT_ASSERT_EQUAL_MESSAGE("Año no correcto",2100,year);
	 	CPPUNIT_ASSERT_EQUAL_MESSAGE("Dia no correcto",1,day);
	 	CPPUNIT_ASSERT_EQUAL_MESSAGE("Mes no correcto",3,mon);
}

void TestingClass::testDiaSuperiorFebrero2100(){

	    double jd;double  salida;
	 	int  year=2110; int mon=1; int day=1; int hr=13; int min=12;double sec=12;

	 	jd=2491722.050139;

	 	sgp4_date::jday(year,mon,day,hr,min,sec,salida);

	 	CPPUNIT_ASSERT_DOUBLES_EQUAL(jd,salida,0.00001f);
}

void TestingClass::testGrado(){
	double valor1[3],valor2[3];
		     valor1[0]=1;
		     valor1[1]=0;
		     valor1[2]=0;

		     double clave=1;

		CPPUNIT_ASSERT_EQUAL(clave,sgp4_math::mag(valor1));
}


void TestingClass::testFichero(){
		char directorio[128];
		char directorio2[128];
		strcpy(directorio,"Nuevo");
		strcpy(directorio2,"Viejo");

		CPPUNIT_ASSERT_EQUAL(true,(sgp4_util::identicos(directorio,directorio2)));
}











